package org.visionlibrary.image.filters.adjustement;

import javax.media.jai.TiledImage;

import org.visionlibrary.image.acquisition.ImageFactory;
import org.visionlibrary.image.model.AbstractFilter;


public class FishOutColor extends AbstractFilter {
	private int[] color = null;
	
	public FishOutColor(int[] color) {
		this.color = color;
	}

	@Override
	public TiledImage applyFilter(TiledImage src, TiledImage dest) {
		if(null == src)
			throw new NullPointerException("Source image is null.");
		if(null == dest)
			dest = (new ImageFactory()).createCompatibleImage(src);
		
		int maxX = src.getWidth();
		int maxY = src.getHeight();
		
		for (int x = 0; x < maxX; x++)
			for (int y = 0; y < maxY; y++) {
				for (int ch = 0; ch < src.getNumBands(); ch++) {
					int c = src.getSample(x, y, ch);
//					if(c == color[ch])
					dest.setSample(x, y, ch, 0);
				}
			}
		
		return dest;
	}
}
